//grideview绑定数据
import 'package:flutter/material.dart';

import 'MyAppBar.dart';

class MyGrideView extends StatelessWidget {
//  final List<String> itemss;
//
//  MyGrideView({Key key, @required this.itemss}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    var ImgList = getImageList();
    return Scaffold(
        appBar: CommonBar(title: 'girdeview使用'),
        body: GridView.builder(
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
            mainAxisSpacing: 2.0,
            crossAxisSpacing: 2.0,
            childAspectRatio: 0.7,
          ),
          itemCount: ImgList.length,
          itemBuilder: (context, index) {
            return Image.network(
              ImgList[index],
              fit: BoxFit.cover,
            );
          },
        ));
  }

  List getImageList(){
    var ImgList = List<String>();

    ImgList.add(
        'http://img5.mtime.cn/mt/2018/10/22/104316.77318635_180X260X4.jpg');
    ImgList.add(
        'http://img5.mtime.cn/mt/2018/10/10/112514.30587089_180X260X4.jpg');
    ImgList.add(
        'http://img5.mtime.cn/mt/2018/11/13/093605.61422332_180X260X4.jpg');
    ImgList.add(
        'http://img5.mtime.cn/mt/2018/11/07/092515.55805319_180X260X4.jpg');
    ImgList.add(
        'http://img5.mtime.cn/mt/2018/11/21/090246.16772408_135X190X4.jpg');
    ImgList.add(
        'http://img5.mtime.cn/mt/2018/11/17/162028.94879602_135X190X4.jpg');
    ImgList.add(
        'http://img5.mtime.cn/mt/2018/11/19/165350.52237320_135X190X4.jpg');
    ImgList.add(
        'http://img5.mtime.cn/mt/2018/11/16/115256.24365160_180X260X4.jpg');
    ImgList.add(
        'http://img5.mtime.cn/mt/2018/11/20/141608.71613590_135X190X4.jpg');
    return ImgList;
  }

}
